package com.wyx.SpringSecurityConfig.controller;

import com.wyx.utils.CommonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * @ClassName AuthorityController
 * @Description TODO
 * @Author 王玉星
 * @Date 2021/8/7 18:10
 * @Version 1.0
 */
@RestController
@RequestMapping("/authority")
public class AuthorityController {

    // 无权限访问响应
    @RequestMapping("/noAuthority")
    public CommonResult noAuthority(){
        return CommonResult.perNoAll();
    }

    // 认证失败响应
    @RequestMapping("/AuthenticationFailed")
    public CommonResult AuthenticationFailed(){
        return CommonResult.MyMessage("认证失败，用户名或密码错误");
    }


    // 退出成功处理器
    @RequestMapping("/logoutOk")
    public CommonResult logoutOk(HttpServletResponse response){
        // 给前端一个空的请求头，让前端将请求头参数设置为空即可
        response.setHeader("token","");
        return CommonResult.Success("退出登录成功😀😀😀");
    }


    // 退出失败处理器
    @RequestMapping("/logoutEr")
    public CommonResult logoutEr(){
        return CommonResult.MyMessage("退出登录失败 😢😢😢");
    }

}
